/*
 *
 * Copyright (c) 2001-2018 泛微软件.
 * 泛微协同商务系统,版权所有.
 * 
 */
package com.engine.demo.cmd;

import com.cloudstore.eccom.constant.WeaMessageCode;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.demo.dao.DemoDao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.Map;

/**
 * @version 1.0
 * @author AndyZhang
 * TODO 
 */
public class DoQueryDemoByID extends AbstractCommonCommand<Map<String,Object>> {

	private final static Log log = LogFactory.getLog(DoQueryDemoByID.class);
	
    private BizLogContext bizLogContext = new BizLogContext();

    public DoQueryDemoByID(Map<String,Object> params,User user) {
        this.params = params;
        this.user = user;
    }

    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
    	WeaResultMsg result=new WeaResultMsg(true);
        RecordSet recordSet=new RecordSet();
        String id =Util.null2String(params.get("id"));
        String sql=DemoDao.getOne();
        recordSet.executeQuery(sql,id);
        if(recordSet.next()){
            result.put("id",recordSet.getString("id"));
            result.put("corp_id",recordSet.getString("corp_id"));
        	result.put("oa_name",recordSet.getString("oa_name"));
            result.put("oa_address",recordSet.getString("oa_address"));
        	result.put("em_name",recordSet.getString("em_name"));
        	result.put("em_url",recordSet.getString("em_url"));
        	result.put("remark",recordSet.getString("remark"));
        	result.success();
            return result.getResultMapAll();
        }
       
        return result.fail("ID does not exist", WeaMessageCode.BS_NOT_FOUND.getCode()).getResultMapAll();
    }
}
